package club.caihappy.test;

import club.caihappy.aop.MathCalculator;
import club.caihappy.config.MainConfigOfAOP;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Created by DELL on 2021/10/13
 **/
public class IOCTest_AOP {
    @Test
    public void test1() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigOfAOP.class);
        //不要自己创建对象
//        MathCalculator mathCalculator = new MathCalculator();
//        int div = mathCalculator.div(1, 2);
        MathCalculator bean = applicationContext.getBean(MathCalculator.class);
        int div = bean.div(1, 0);
        applicationContext.close();
    }
}
